package top.zhangjianyong.tools.constant;

import top.zhangjianyong.tools.entity.Vegetable;

import java.util.Arrays;
import java.util.function.Predicate;

import static top.zhangjianyong.tools.constant.CanteenMealFilter.*;


public enum CanteenMeal {

    NOODLE("面", NOODLE_FILTER),
    NOODLE_NO_JTM("面（除了姜汤面）", NOODLE_NO_JTM_FILTER),
    HAMBURGER("汉堡", HAMBURGER_FILTER),
    TAOCAN_E("套餐E", TAOCAN_E_FILTER),
    TAOCAN_C("套餐C", TAOCAN_C_FILTER),
    TAOCAN_D("套餐D", TAOCAN_D_FILTER),
    ;

    public final String name;
    public final Predicate<Vegetable> doFilter;

    CanteenMeal(String name, Predicate<Vegetable> doFilter) {
        this.name = name;
        this.doFilter = doFilter;
    }


    public static CanteenMeal getByName(String name) {
        return Arrays.stream(values())
                .filter(m -> m.name.equals(name))
                .findFirst().orElseThrow(() -> new RuntimeException("未找到对应的餐点类型"));
    }
}
